{php include wl_template('common/header');}
    <script>
        $(function(){
            if(typeof (ds) == "function") {
                ds = function(){};
            }
        });
        function escapeHtml(text) {
            var a=text.replace(/(\&lt;)/g,"<");
            var b=a.replace(/(\&gt;)/g,">");
            var c=b.replace(/(\&amp;)/g,"\&");
            var d=c.replace(/(\&quot;)/g,"\"");
            return d;
        }
    </script>
    <style>
        textarea{
            border:1px solid #ddd;
            width: 100%;
            height: 100px;
            padding:2px;
        }
        #btn_judement{
            padding: 5px 10px;
            background: #ff5c67;
            border-radius: 6px;
            color: #fff;
        }
        .weui_textarea_counter{
            float: left;
        }
        /*.modal-in{*/
            /*margin: 0!important;*/
            /*position: fixed;*/
            /*top: 25%;*/
            /*left: 22%;*/
            /*width: 52%;*/
            /*height: 20%;*/
            /*background: rgba(0,0,0,0.8);*/
            /*color:#fff!important;*/
            /*border-radius: 5px;*/
        /*}*/
        /*.modal>div{*/
            /*position: relative;*/
            /*top: 25%;*/
            /*left: 25%;*/
        /*}*/
        /*.modal span{*/
            /*padding: 2px 6px;*/
            /*margin-left: 3px;*/
        /*}*/
        .choose>ul{
            padding: 0;
            margin: 0;
        }
        .choose li{
            float:left;
            width:21%;
            height:25px;
            text-align: center;
            line-height: 25px;
            background: #ff5c67;
            border-radius: 5px;
            margin:5px;
            list-style: none;
            font-size: 12px;
            color: #fff;
            opacity: 0.6;
        }
        .choose li.active{
            opacity: 1;
        }
        /*.weui_uploader{*/
            /*display: none;*/
        /*}*/
        .zhuiping{
            font-size: 12px;
            background: #aaa;
            padding: 3px 6px;
            border-radius: 4px;
            color: #fff;
        }
        /*.toast{*/
            /*width:50%;*/
            /*height:50px;*/
            /*line-height: 50px;*/
            /*text-align: center;*/
        /*}*/
        /*.modal-out{*/
            /*display: none!important;*/
        /*}*/
        .PL img{
            margin-right:10px;
            float:left;
            width:40px;
            height:40px;
            border-radius: 50%;
        }
        .PL span{
            display: block;
            color: #aaa;
            font-size: 12px;
            margin-top: 5px;
        }
        .iconal-xing.active{
            color: #ff5c67;
        }
        .evaluate>div{
            display: flex;
            display: -webkit-flex;
            align-items: center;
            -webkit-align-items: center;
        }
        .evaluate ul{
            /*display: flex;*/
            /*display: -webkit-flex;*/
            /*padding: 5px 10px;*/
            margin: 5px 10px;
        }
        .evaluate ul>li{
            color: #ccc;
            padding: 0 5px;
            font-size: 24px;
            /*display: inline-block;*/
            float: left;
        }
        ul{
            background-color: #fff!important;
        }
        ul:focus{
            border: inherit;
            background-color: #fff;
            outline: inherit;
        }

    </style>
</head>

<?php
			$jud_id = pdo_fetch("select * from ".tablename('tg_judgment')." where col_id=:gid",array(':gid'=>$_GPC['id']));
$main_content =  pdo_fetch("select * from ".tablename('tg_judgment_content')." where  judgment_id=:judgment_id and who=0 and isfirst=0 order by update_time asc ",array(':judgment_id'=>$jud_id['id']));
//$allcontent = pdo_fetchall("select * from ".tablename('tg_judgment_content')." where  judgment_id=:judgment_id and isfirst=1 order by update_time asc ",array(':judgment_id'=>$jud_id['id']));
$allcontent = pdo_fetchall("select * from ".tablename('tg_judgment_content')." where  judgment_id=:judgment_id   order by update_time asc ",array('judgment_id'=>$jud_id['id']));
$evaluates = pdo_fetchall("SELECT * FROM " . tablename('tg_evaluate') . " WHERE uniacid = :uniacid ORDER BY id DESC",array(':uniacid'=>$_W['uniacid']));
?>
<body style="background: #fff">

<div style="background: #fff;">
    <div style="padding: 20px;">
        <div class="commodity_info" >
            <dt style="height:85px;margin-right:10px;float:left;background-position:4px 0;"><img src="" width="85" height="85" alt=""></dt>
            <dd style="font-size: 14px;height:85px;">
                <div></div>
                <div class="attr" id="ord_imes">
                    <span style="display:block; color:#aaa;"></span>
                </div>
                <span style="margin-left:0px; margin-top:1em;color:#aaa;" class="spec_items options" id="in">
                    <span style="margin-left: 0px;"><span color="#888" size="2"></span></span>
                </span>
            </dd>
        </div>

        <div class="PL" {if empty($jud_id)}style="display: none"{/if}>
            <img src="{$jud_id['avatar']}" alt=""/>
            <span>{$jud_id['openname']}</span>
            <span>{php echo date('Y-m-d H:i:s',$jud_id['create_time'])}</span>
        </div>
        <div style="font-size: 14px; font-weight: 400; word-wrap: break-word; margin-top: 10px;">{$main_content['content']}</div>
        {loop $allcontent $content}
        {if $content['who']== 1}<label class="zhuiping">商家回复</label>{/if}
        {if $content['who']== 0}<label class="zhuiping">用户追评</label>{/if}<span style="margin-left:20px; color: #b8c0cc; font-size: 12px;"><?php echo date('Y-m-d H:i:s',$content['update_time']); ?></span>
        <div style="margin-left:10px;font-size: 12px; font-weight: 400;word-break: break-all;">{$content['content']}</div>
        {/loop}
        <div class="choose" {if !empty($jud_id)}style="display: none"{/if}>
            <ul>
                <li data-name="ishaoyong">有意思</li>
                <!--<li data-name="iszhengpin"></li>-->
                <li data-name="ispianyi">有意义</li>
                <li data-name="iswuliu">效果赞</li>
                <li data-name="iszhiliang">品质好</li>
                <li data-name="isfuwu">服务好</li>
                <li data-name="isqita">其他</li>
            </ul>
        </div>
        <div style="clear: both"></div>
        <div class="pingjia" {if !empty($jud_id)}style="display: none"{/if}>
            <div class="evaluate">
                {loop $evaluates $i}
                        <div class="{$i['id']}" data-value="{$i['weight']}" data-num="">
                            <span>{$i['name']}</span>
                            <ul>
                                <li class="iconal-xiaolian1" data-num="1"></li>
                                <li class="iconal-xiaolian1" data-num="2"></li>
                                <li class="iconal-xiaolian1" data-num="3"></li>
                                <li class="iconal-xiaolian1" data-num="4"></li>
                                <li class="iconal-xiaolian1" data-num="5"></li>
                            </ul>
                        </div>
                {/loop}
            </div>
        </div>
        <div class="judement_content">
            <div class="weui_cell">
                <div class="weui_cell_bd weui_cell_primary">
                    <textarea onKeyUp="textCounter('judement_content',this)"  name="judement_content" id="content{$si}" class="weui_textarea txt" placeholder="您的评价对我们都是很重要的参考" rows="3" maxlength="200"></textarea>
                    <div class="weui_textarea_counter"><span>0</span>/200</div>
                </div>
            </div>
        </div>
        <div class="page">
            <div class="page__bd">
                <div class="weui-gallery" id="gallery">
                    <span class="weui-gallery__img" id="galleryImg"></span>
                    <div class="weui-gallery__opr">
                        <a href="javascript:" class="weui-gallery__del">
                            <i class="weui-icon-delete weui-icon_gallery-delete"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="button_sp_area">
            <a class="weui_btn weui_btn_plain weui_btn_warn " id="sub{$si}" orderno="{$order['orderno']}" style="display: none;" openid="{$order['openid']}"  uniacid="{$order['uniacid']}" gid="{$gs['id']}" item="{$v['item']}">sub{$si}</a>
        </div>
        <a class="weui_btn weui_btn_plain weui_btn_warn " id="btn_judement" style="float: right;" >提交</a>
        </div>
</div>
<div style="height:50px;"></div>


</body>
<script>
    //加载评价详情
//    $.get("{php echo app_url('goods/judgment_list',array('op' => 'ajaxJudgmt'))}",{id:"{$_GPC['id']}"},function(res){
//        var data=JSON.parse(res);
//        console.log(data);
//    });

    $.ajax({
        type: "get",
        url: "{php echo app_url('goods/judgment_list',array('op' => 'ajax_detail'))}",
        data:{"id":"{$_GPC['id']}"},
        dataType: "json",
        success: function(data){
            console.log(data);
            $('#ord_imes').prev().html(data.goods.gname);
            $('.commodity_info>dt>img').attr('src',data.goods.gimg).attr('data-jishiid',data.jishi_id).attr('data-gid',data.goods.id);//图片
            $('#ord_imes>span').html('单价：￥'+data.goods.oprice);
            var html='';
            for(var i=0;i<5;i++){
                if(i<Math.round(data.score)){
                    html+='<li data-num='+(i+1)+' class="iconal-xing active"></li>';
                }else{
                    html+='<li data-num='+(i+1)+' class="iconal-xing"></li>';
                }
            }
        }
    });

    $('.choose').on('click','ul li',function(e){
        if(e.currentTarget.className==''){
            e.currentTarget.className='active';
        }else{
            e.currentTarget.className='';
        }
    });
    $('#btn_judement').on('click',function(){
        var lis=$('.choose li');
        var j= 0,BQ={iszhuijia:0};
        for(var i=0;i<lis.length;i++){
            if($(lis[i]).hasClass('active')){
                BQ[($(lis[i]).attr('data-name'))]=1;
                j++;
            }
        }
        if($('#content').val()==''){
            $.toast('请填写评价内容','text');
            return false;
        }

        BQ['jud_id']="{$jud_id['id']}";
        BQ['id']="{$_GPC['id']}";
        BQ['content']=$('#content').val();

        var DATA={
            jishiid:$('.commodity_info>dt>img').attr('data-jishiid'),
            gid:$('.commodity_info>dt>img').attr('data-gid'),
            cartid:"{$_GPC['id']}",
            evas:[]
        };
        for(var i=0;i<$('.evaluate>div').length;i++){
            var ee=$($('.evaluate>div')[i]);
            var obj={};
            if(ee.attr('data-num')==""&&"{$jud_id}"==""){
                $.toast('请评价后再提交','text');
                return false;
            }
            obj['name']=ee.children('span').html();
            obj['weight']=ee.attr('data-value');
            obj['score']=Number(ee.attr('data-value'))*Number(ee.attr('data-num'));
            DATA.evas.push(obj);
        }

        if("{$jud_id}"==""){
            $.post(
                "{php echo app_url('goods/judgment_list',array('op' => 'evaluate'))}",
                DATA ,
                function(data){
                }
            )
        }
        $.post(
            "{php echo app_url('goods/judgment_list',array('op' => 'judgment'))}",
            BQ,
            function(data){
                if(Number(data)>0){
                    $.toast('评价成功');
                    setTimeout(function(){location.reload();},700)
                }else{
                    $.toast('提交失败，请重新提交');
                }
            }
        );

    });


    function textCounter(field,e) {
        console.log($(e).val());
        // 函数，3个参数，表单名字，表单域元素名，限制字符；
        if ($(e).val().length > 200) {
            //如果元素区字符数大于最大字符数，按照最大字符数截断；
            field.value = field.value.substring(0, 200);
        } else {
            //在记数区文本框内显示剩余的字符数；
            $(e).next().children('span').html($(e).val().length);
        }
    }
    $('.evaluate ul').on('click','li',function(){
        $(this).parent().parent().attr('data-num',$(this).attr('data-num'));
        $(this).css('color','#ff5c67').prevAll('li').css('color','#ff5c67');
        $(this).nextAll('li').css('color','#ccc');
    })
</script>